// Modified according to:
//     https://github.com/atom/one-dark-syntax/

// Config -----------------------------------
@syntax-hue: 220;
@syntax-saturation: 13%;
@syntax-brightness: 18%;

// Monochrome -----------------------------------
@mono-1: hsl(@syntax-hue, 14%, 71%); // default text
@mono-2: hsl(@syntax-hue, 9%, 55%);
@mono-3: hsl(@syntax-hue, 10%, 40%);

// Colors -----------------------------------
@hue-1: hsl(187, 47%, 55%); // <-cyan
@hue-2: hsl(207, 82%, 66%); // <-blue
@hue-3: hsl(286, 60%, 67%); // <-purple
@hue-4: hsl(95, 38%, 62%); // <-green

@hue-5: hsl(355, 65%, 65%); // <-red 1
@hue-5-2: hsl(5, 48%, 51%); // <-red 2

@hue-6: hsl(29, 54%, 61%); // <-orange 1
@hue-6-2: hsl(39, 67%, 69%); // <-orange 2

// Base colors -----------------------------------
@syntax-fg: @mono-1;
@syntax-bg: hsl(@syntax-hue, @syntax-saturation, @syntax-brightness);
@syntax-gutter: darken(@syntax-fg, 26%);
@syntax-guide: fade(@syntax-fg, 15%);
@syntax-accent: hsl(@syntax-hue, 100%, 66%);

// Official Syntax Variables -----------------------------------

// General colors
@syntax-text-color: @syntax-fg;
@syntax-cursor-color: @syntax-accent;
@syntax-selection-color: lighten(@syntax-background-color, 10%);
@syntax-selection-flash-color: @syntax-accent;
@syntax-background-color: @syntax-bg;

// Guide colors
@syntax-wrap-guide-color: @syntax-guide;
@syntax-indent-guide-color: @syntax-guide;
@syntax-invisible-character-color: @syntax-guide;

// For find and replace markers
@syntax-result-marker-color: fade(@syntax-accent, 24%);
@syntax-result-marker-color-selected: @syntax-accent;

// Gutter colors
@syntax-gutter-text-color: @syntax-gutter;
@syntax-gutter-text-color-selected: @syntax-fg;
@syntax-gutter-background-color: @syntax-bg; // unused
@syntax-gutter-background-color-selected: lighten(@syntax-bg, 2%);

// Git colors - For git diff info. i.e. in the gutter
@syntax-color-renamed: hsl(208, 100%, 60%);
@syntax-color-added: hsl(150, 60%, 54%);
@syntax-color-modified: hsl(40, 60%, 70%);
@syntax-color-removed: hsl(0, 70%, 60%);

// For language entity colors
@syntax-color-variable: @hue-5;
@syntax-color-constant: @hue-6;
@syntax-color-property: @syntax-fg;
@syntax-color-value: @syntax-fg;
@syntax-color-function: @hue-2;
@syntax-color-method: @hue-2;
@syntax-color-class: @hue-6-2;
@syntax-color-keyword: @hue-3;
@syntax-color-tag: @hue-5;
@syntax-color-attribute: @hue-6;
@syntax-color-import: @hue-3;
@syntax-color-snippet: @hue-4;

// Custom Syntax Variables -----------------------------------
// Don't use in packages

@syntax-cursor-line: hsla(
  @syntax-hue,
  100%,
  80%,
  0.04
); // needs to be semi-transparent to show search results

@syntax-deprecated-fg: darken(@syntax-color-modified, 50%);
@syntax-deprecated-bg: @syntax-color-modified;
@syntax-illegal-fg: white;
@syntax-illegal-bg: @syntax-color-removed;

pre {
  font-family: Menlo, Monaco, Consolas, 'Courier New', monospace;
  direction: ltr;
  text-align: left;
  white-space: pre;
  word-spacing: normal;
  word-break: normal;

  padding: 1em;
  margin: 0.5em 0;

  overflow: auto;
  line-height: 1.5;
  tab-size: 4;
  hyphens: none;
  color: @syntax-text-color;
  background-color: contrast(
    @syntax-background-color,
    lighten(@syntax-background-color, 4%),
    darken(@syntax-background-color, 6%)
  ) !important;
  border: contrast(
    @syntax-background-color,
    lighten(@syntax-background-color, 16%),
    darken(@syntax-background-color, 16%)
  );
  border-radius: 3px;
}

pre[class*='language-'] {
  // presentation mode padding
  padding: 1em;
}

code[class*='language-'],
pre[class*='language-'] {
  .token.comment,
  .token.prolog,
  .token.doctype,
  .token.cdata {
    color: @mono-3;
  }

  /*
.token.punctuation {
  color: #96CBFE;
}
*/

  .namespace {
    opacity: 0.7;
  }

  .token.constant {
    color: @hue-6;
  }

  /*
.token.property {
}
*/

  .token.boolean,
  .token.number,
  .token.function-name {
    color: @hue-6;
  }

  .token.tag {
    color: @hue-5;
  }

  /*
.token.deleted {
}

.token.inserted {
}
*/

  .token.symbol {
    color: @hue-1;
  }

  .token.selector {
    color: @hue-3;
  }

  .token.attr-name {
    // .attribute-name
    color: @hue-6;
  }

  .token.string {
    color: @hue-4;
  }

  .token.char {
    color: @hue-1;
  }

  /*
.token.builtin {
  color: @green;
}

.token.entity {
  color: #FFD2A7;
}
*/

  .token.url {
    // link
    color: @hue-1;
  }

  .token.operator {
    color: @mono-1;
  }

  .token.atrule,
  .token.attr-value,
  .token.keyword {
    color: @hue-3;
  }

  .token.function {
    color: @hue-2;
  }

  .token.class-name {
    color: @hue-6-2;
  }

  .token.variable {
    color: @hue-6;
  }

  .token.regex {
    color: @hue-1;
  }

  .token.important {
    color: @hue-5;
  }

  .token.important,
  .token.bold {
    font-weight: bold;
  }
  .token.italic {
    font-style: italic;
  }

  .token.entity {
    cursor: help;
  }

  /*
&.line-numbers {
  .line-numbers-rows>span:before {
  }
}
*/
}

/* highlight */
pre[data-line] {
  position: relative;
  padding: 1em 0 1em 3em;
}
pre[data-line] .line-highlight-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  background-color: transparent;
  display: block;
  width: 100%;
}

pre[data-line] .line-highlight {
  position: absolute;
  left: 0;
  right: 0;
  padding: inherit 0;
  margin-top: 1em;
  background: hsla(24, 20%, 50%, 0.08);
  background: linear-gradient(
    to right,
    hsla(24, 20%, 50%, 0.1) 70%,
    hsla(24, 20%, 50%, 0)
  );
  pointer-events: none;
  line-height: inherit;
  white-space: pre;
}

pre[data-line] .line-highlight:before,
pre[data-line] .line-highlight[data-end]:after {
  content: attr(data-start);
  position: absolute;
  top: 0.4em;
  left: 0.6em;
  min-width: 1em;
  padding: 0 0.5em;
  background-color: hsla(24, 20%, 50%, 0.4);
  color: hsl(24, 20%, 95%);
  font: bold 65%/1.5 sans-serif;
  text-align: center;
  vertical-align: 0.3em;
  border-radius: 999px;
  text-shadow: none;
  box-shadow: 0 1px white;
}

pre[data-line] .line-highlight[data-end]:after {
  content: attr(data-end);
  top: auto;
  bottom: 0.4em;
}
